package com.fakesmoker.aidawnda.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fakesmoker.aidawnda.model.dto.statistic.AppAnswerCountDTO;
import com.fakesmoker.aidawnda.model.dto.statistic.AppAnswerResultCountDTO;
import com.fakesmoker.aidawnda.model.entity.UserAnswer;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author 86188
* @description 针对表【user_answer(用户答题记录)】的数据库操作Mapper
* @createDate 2024-11-07 18:20:56
* @Entity generator.domain.UserAnswer
*/
public interface UserAnswerMapper extends BaseMapper<UserAnswer> {

        @Select("select appId, count(userId) as answerCount from user_answer " +
                "group by appId order by answerCount desc")
        List<AppAnswerCountDTO> doAppAnswerCount();

        @Select("select appId,count(distinct userId)as countUser from user_answer " +
                "group by appId   order by countUser desc")
        List<AppAnswerCountDTO> doAppUserCount();

        @Select("select resultName,count(resultName)as resultNameCount from user_answer " +
                "where appId =#{appId} group by resultName " +"order by resultNameCount desc")
        List<AppAnswerResultCountDTO> doAppAnswerResultCount(Long appId);

}




